\subsection{Блок-схемы}

\begin{figure}[ht]  
\begin{subfigure}[t]{0.5\textwidth}
\centering
\begin{tikzpicture}[node distance = 1cm, auto]
        \node [cloud]                                                 (start)  {Начало};
        \node [block,       below of = start  ]                       (phase1) {$i:=1$};
        \node [decision,    below of = phase1]                        (ilt15)  {$i \leq 15?$};
        \node [block,       below of = ilt15, node distance = 2.5cm]  (phase2) {$x:=f(i)$};
        \node [decision,    below of = phase2]                        (simple) {$IsPrime(x)?$};
        \node [print_block, below of = simple, node distance = 2.5cm] (out1)   {x, ` - простое`};
        \node [block,       below of = out1]                          (iter)   {$i:=i+1$};
        \node [print_block, right of = out1, node distance = 3.5cm]   (out3)   {x, ` - не простое`};
        \node [print_block, right of = phase2, node distance = 3.5cm] (out2)   {`Все i проверены`};
        \node [cloud, below of = out3]                                (finish) {Конец};

        \path [line] (start)  -- (phase1);
        \path [line] (phase1) -- (ilt15);
        \path [line] (ilt15)  -- node {Да}(phase2);
        \path [line] (phase2) -- (simple);
        \path [line] (simple) -- node {Да}(out1);
        \path [line] (out1)   -- (iter);
        \path [line] (iter)   -| ++(-1.5, 9.5) -| (ilt15);
        \path [line] (ilt15)  -| node [near start] {Нет} (out2);
        \path [line] (simple) -| node [near start] {Нет}  (out3);
        \path [line] (out3)   -- (finish);
        \path [line] (out2)   |- ++(1.8,-1)    |- ++(-1.8,-4) -- (finish);         
\end{tikzpicture}
\caption{Основная программа}
\label{bs1_1}
\end{subfigure}
%~
\begin{subfigure}[t]{0.4\textwidth}
  \centering
  \begin{tikzpicture}[node distance = 1cm, auto]
      \node [cloud]                                               (start)         {IsPrime(x)};
      \node [block, below of = start]                             (phase1)    {$y:=\sqrt{x}$};
      \node [block, below of = phase1]                            (phase1_1)  {$i:=2$};
      \node [decision, below of = phase1_1]                       (ilty)      {$i<y?$};
      \node [decision, below of = ilty, node distance = 3.5cm]    (ymodi)     {x mod i = 0?};
      \node [block, below of = ymodi, node distance = 2.5cm]      (phase2)    {$i:=i+1$};

      \path [line] (start)    -- (phase1);
      \path [line] (phase1)   -- (phase1_1);
      \path [line] (phase1_1) -- (ilty);
      \path [line] (ilty)     -- node [near start] (yes1){Да} (ymodi);
      \path [line] (ymodi)    -- node [near start] (no2){Нет} (phase2);
      \path [line] (phase2)   -| ++(-1.5,7.5) -| (ilty); 

      \node [block, right of = yes1,  node distance = 2.5cm]      (false)     {$s:=true$};
      \node [block, below of = false, node distance = 2.5cm]        (true)      {$s:=false$};
      \node [block, below of = true, node distance = 1.2cm]         (inx)      {\textit{IsPrime := s}};
      \node [cloud, below of = inx, node distance = 1.5cm]          (finish)    {Конец};
      
      \path [line] (ilty)     -| node [near start] {Нет} (false);
      \path [line] (ymodi)    -| node [near start] {Да} (true);
      \path [line] (false)    -| ++(1.5,-3) -| (inx);
      \path [line] (true)     -- (inx);
      \path [line] (inx)     -- (finish);


    \node [cloud, right of = start,  node distance = 3cm]         (start1)    {f(i)};
    \node [block, below of = start1, node distance = 1.5cm]       (action1)   {$f:=i^2+i+17$};
    \node [cloud, below of = action1]                             (finish1)   {Конец};
    
    \path [line] (start1)     -- (action1);
    \path [line] (action1)    -- (finish1);

      
  \end{tikzpicture}
  \caption{Функции f(i) и IsPrime(x)}
  \label{bs1_2}
\end{subfigure}
\caption{Блок-схемы к заданию \textnumero 1}
  \label{bs1}
\end{figure}
